﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using ZX.OA.Model;

namespace ZX.OA.DAL
{
    public class EmployeeInfoDAL
    {
        Entity entity = new Entity();
        /// <summary>
        /// 显示用户信息
        /// </summary>
        /// <returns></returns>
        public List<EmployeeInfo> ShowEmp()
        {
            return entity.EmployeeInfo.ToList();
        }
        /// <summary>
        /// 获取dept表信息
        /// </summary>
        /// <returns></returns>
        public List<DeptInfo> GetDeptId()
        {
            return entity.DeptInfo.ToList();
        }
        /// <summary>
        /// 添加用户信息
        /// </summary>
        /// <param name="emp"></param>
        /// <returns></returns>
        public bool AddEmploylee(EmployeeInfo emp)
        {
            entity.EmployeeInfo.Add(emp);
            return entity.SaveChanges() > 0;
        }
        /// <summary>
        /// 删除用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool delEmployeeInfo(int id)
        {
            EmployeeInfo emp = entity.EmployeeInfo.Find(id);
            entity.EmployeeInfo.Remove(emp);
            return entity.SaveChanges() > 0;
        }
        /// <summary>
        /// 根据编号获取用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public EmployeeInfo getemp(int id)
        {
            return entity.EmployeeInfo.Find(id);
        }
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="emp"></param>
        /// <returns></returns>
        public bool uptemp(EmployeeInfo emp)
        {
            entity.Entry(emp).State = System.Data.EntityState.Modified;
            return entity.SaveChanges() > 0;
        }
      


    }
}
